package homework;

import java.util.Arrays;
import java.util.Random;

public class Demo11 {

    public static void main(String[] args) {
        int[] arr=new int[5];
        Random random=new Random();
        for (int i = 0; i < 10000; i++) {
            int num=random.nextInt(100000000); 
            int index=Arrays.binarySearch(arr, num);
            if (index==0||index==-1) {
                continue;
            }
            if (index<0) {
                index=-(index+1);
            }
            for (int j = 1; j < index; j++) {
                arr[j-1]=arr[j];
            }
            arr[index-1]=num;
            //System.out.println(Arrays.toString(arr));
        }
        System.out.println("最终结果："+Arrays.toString(arr));
    }

}
